﻿// -----------------------------------------------------------------------
// <copyright file="Memory.cs" company="DarkBone">
// DarkBone
// </copyright>
// -----------------------------------------------------------------------

namespace DarkBone.Engine.SC2
{
   using System;
   using System.Diagnostics.CodeAnalysis;

   /// <summary>
   /// Interprets SC2 Process
   /// </summary>
   public sealed class Memory
   {
      /// <summary>
      /// Ptr to mapInfo
      /// </summary>
      [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate",
         Justification = "Reviewed. Suppression is OK here.")]
      public static IntPtr PointerMap = (IntPtr)0x1B8CDD4;

      /// <summary>
      /// Ptr to units
      /// </summary>
      [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate",
         Justification = "Reviewed. Suppression is OK here.")]
      public static IntPtr PointerUnits = (IntPtr)0x01C06F00; 

      /// <summary>
      /// Ptr to number of units
      /// </summary>
      [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate",
         Justification = "Reviewed. Suppression is OK here.")]
      public static IntPtr PointerUnitsNum = (IntPtr)(int)PointerUnits - 0x60;

      /// <summary>
      /// Ptr to current player slot
      /// </summary>
      [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate",
         Justification = "Reviewed. Suppression is OK here.")]
      public static IntPtr PointerCurrentPlayerSlot = (IntPtr)0x158f24c;

      /// <summary>
      /// Ptr to players
      /// </summary>
      [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate",
         Justification = "Reviewed. Suppression is OK here.")]
      public static IntPtr PointerPlayers = (IntPtr)0x1BFE1F8;

      /// <summary>
      /// Ptr to player accounts
      /// </summary>
      [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate",
         Justification = "Reviewed. Suppression is OK here.")]
      public static IntPtr PointerPlayersAccount = (IntPtr)0x3165D8C;

      /// <summary>
      /// Ptr to game time, 0xFFFFFFFF in lobby SHL 4, to get secs
      /// </summary>
      [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate",
         Justification = "Reviewed. Suppression is OK here.")]
      public static IntPtr PointerGameTime = (IntPtr)0x0157C300;

      /// <summary>
      /// Length of player struct
      /// </summary>
      [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate",
         Justification = "Reviewed. Suppression is OK here.")]
      public static int NUMOFPLAYERS = 0x10;

      /// <summary>
      /// Ptr to game time, 0xFFFFFFFF in lobby SHL 4, to get secs
      /// </summary>
      [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate",
         Justification = "Reviewed. Suppression is OK here.")]
      public static IntPtr PointerLoadedMpq = (IntPtr)0x02F90858 + 1;
      
      /// <summary>
      /// Length of unit struct
      /// </summary>
      [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate",
         Justification = "Reviewed. Suppression is OK here.")]
      public static int UNITSTRUCTSIZE = 0x180;

      /// <summary>
      /// Length of player struct
      /// </summary>
      [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate",
         Justification = "Reviewed. Suppression is OK here.")]
      public static int PLAYERSTRUCTSIZE = 0x8A8;

      /// <summary>
      /// Length of player struct
      /// </summary>
      [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate",
         Justification = "Reviewed. Suppression is OK here.")]
      public static int PLAYERACCOUNTSTRUCTSIZE = 0xAC;

      /// <summary>
      /// Length of player struct
      /// </summary>
      [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:FieldsMustBePrivate",
         Justification = "Reviewed. Suppression is OK here.")]
      public static IntPtr PointerTeamColor = (IntPtr)0x02F97E80; // (058379C0, 02F97ED8, 02F97E80, 02F9795C, 0x02000000 if teamcolor is on. 0x00000000 if off)
      

      /// <summary>
      /// Interprets SC2 Unit
      /// </summary>
      public struct UnitStruct
      {
         /// <summary>
         /// unit identifer
         /// </summary>
         public short Id;

         /// <summary>
         /// X coord
         /// </summary>
         public int X;

         /// <summary>
         /// Y coord
         /// </summary>
         public int Y;

         /// <summary>
         /// Model number
         /// </summary>
         public int ModelNumber;

         /// <summary>
         /// Unit owner
         /// </summary>
         public int Owner;
      }

      /// <summary>
      /// Interprets SC2 Player
      /// </summary>
      public struct PlayerStruct
      {
         /// <summary>
         /// Player status
         /// </summary>
         public byte Status;

         /// <summary>
         /// Player name
         /// </summary>
         public string Name;

         /// <summary>
         /// Player type
         /// </summary>
         public byte Type;

         /// <summary>
         /// Color id
         /// </summary>
         public byte ColorIndex;

         /// <summary>
         /// Player index
         /// </summary>
         public int Index;

         /// <summary>
         /// Player team slot id
         /// </summary>
         public byte Teamslot;

         /// <summary>
         /// Player account info
         /// </summary>
         public string Account;

         /// <summary>
         /// Army size
         /// </summary>
         public int ArmySize;
      }
   }
}